<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui-date,auto-complete,dtvalidate,layui,chosen'}){%>
    <style type="text/css">
        body{padding-top:10px;}
        *{margin:0;padding:0;list-style-type:none;}
        a,img{border:0;}
        .demo h2{font-size:16px;color:#3366cc;height:30px;}
        .demo li{float:left;}
    </style>
    <%}%>
</head>

<body>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div id="toolbar" class="btn-group" style="margin-bottom:5px;">
                <button  class="report-btn layui-btn  layui-btn-sm"  style="margin-top: -6px;margin-left: -4px">
                    <i class="fa fa-check-square-o" aria-hidden="true"></i> 生成报表
                </button>
                <button  class="export-btn layui-btn  layui-btn-sm" style="margin-top: -6px;margin-left: -2px">
                    <i class="fa fa-download" aria-hidden="true"></i> 导出当前数据
                </button>
            </div>
    <!-- START 数据表格 -->
    <table id="portTable"
           data-toolbar="#toolbar"
           data-side-pagination="server"
           data-pagination="true"
           data-resizable="true"
           data-url="/sea/finance/freightTaxPredict/findByCnd.do"
           data-page-size="15"
           class="table table-striped table-hover"
    >
    </table>
        </div>
    </div>
    <!-- END 数据表格 -->
</div>

<div id="layer_supplier_window" style="display: none;overflow-x: hidden;overflow-y: hidden">
    <!-- START 内容部分 -->
    <div class="container" >
        <form class="form-horizontal" id="info-supplier-form" method="post" autocomplete="off" style="margin: auto">
            <div class="form-group" style="margin-top: 20px">
                <label class="category control-label col-sm-2" style="max-width: 100px">预估总运费</label>
                <div class="col-sm-6" style="max-width: 300px;max-height: 300px;">
                    <input type="text" id="freight" name="freight" value="" class="form-control" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"/>
                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="control-label col-sm-7" style="max-width: 100px"></label>
                <button type="button" class="save-produce-btn btn btn-primary">
                    <i class="fa fa-save"></i> 保存
                </button>
            </div>
        </form>
    </div>
    <!-- END 内容部分 -->
</div>

<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,dtvalidate,dtvalidate-lang-zh_cn,bootstrap-table-zh-CN,laydate,layer,chosen,chosen-demo'}){}%>
<script>



    var $portTable = $('#portTable');
    $(function(){
        //START 表格配置
        $portTable.bootstrapTable({
            pageSize:30,
            pageList: [10, 15, 20, 200,2000],
            columns: [
                {
                    title: '渠道',
                    field: 'productChannelName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: 'SKU',
                    field: 'productSku',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '产品名称',
                    field: 'productName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '含税价',
                    field: 'productPriceCny',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '最低不含税价',
                    field: 'productUnitPriceCny',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '预估运费',
                    field: 'productFreight',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '预估关税',
                    field: 'productTax',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '体积',
                    field: 'productVolume',
                    align: 'center',
                    valign: 'middle'
                }
            ],
            onLoadSuccess : function(){

            }
        });


        //END 表格配置
    });
    $('.report-btn').on('click',function () {
        layer.open({
            type:1,
            title:'生成预估报表',
            area:['450px','270px'],
            skin:'layui-layer-lan',//layui-layer-molv ;layui-layer-lan;layui-layer-rim;layer-window
            shadeClose:false,
            resize: false,
            scrollbar: false,
            maxmin: false,//出现最大化按钮
            content:$('#layer_supplier_window')
        })
    });


    $(".save-produce-btn").on('click',function () {
        var freight = $("#freight").val();
        if (freight == '') {
            parent.layer.msg('请先填写总运费！', {icon: 0, time: 1500, shade: [0.8, '#393D49']});
            return;
        }
        var flag = true;
        if (flag == true) {
            var index = layer.load(2, { //icon支持传入0-2
                shade: [0.1, '#fff'], //0.5透明度的灰色背景
                content: '正在生成报表,请稍后...',
                success: function (layero) {
                    layero.find('.layui-layer-content').css({
                        'padding-top': '39px',
                        'margin-left': '-50px',
                        'width': '300px',
                        'font-color': 'red',
                        'font-size': '20px'
                    });
                }
            });
            $.ajax({
                url: "/sea/finance/freightTaxPredict/predict",
                data: {
                    freight: freight
                },
                type: "post",
                success: function (data) {
                    if (data.ok) {
                        layer.msg("生成成功！", {
                            icon: 0, btn: ['确定'], time: 0, shade: [0.8, '#393D49'], yes: function (index, layero) { // 默认的是 按钮一
                                layer.closeAll();
                                $portTable.bootstrapTable('refresh');
                            }
                        });
                    } else {
                        layer.msg(data.msg, {
                            icon: 0, btn: ['确定'], time: 0, shade: [0.8, '#393D49'], yes: function (index, layero) { // 默认的是 按钮一
                                layer.closeAll();
                            }
                        });
                    }
                },
            });
        }
    })

    $('.search-btn').on('click',function(){
        $portTable.bootstrapTable('refresh', { url:'${ctxPath}/sea/supply/buy/findByCnd.do?'+$('#search-form').serialize() });
    });

    $(".export-btn").click(function () {
        window.location.href='/sea/finance/freightTaxPredict/export.do?'+$('#search-form').serialize();
    });
</script>
</body>
</html>
